const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

const dev = process.env.NODE_ENV === "development";
const production = !dev;

const pages = {
  index: {
    entry: 'src/container/main.js',
    template: 'public/index.html'
  },
  iframe: {
    entry: 'src/main.js',
    template: 'public/iframe.html'
  }
};

module.exports = {
  publicPath: './',
  pages,
  css: {
    sourceMap: production,
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: {
            "primary-color": "#52CBFC",
            "link-color": "#52CBFC",
            "border-radius-base": "2px",
            "btn-danger-bg": "#FE85AE",
            "btn-danger-border": "#FE85AE",
            // "public-path": `~'${publicPath}'`, // less variable escaping
          },
          javascriptEnabled: true
        }
      },
    },
  },
  configureWebpack: config => {
    const plugins = [];
    if (production) {
      plugins.push(
        new UglifyJsPlugin({
          uglifyOptions: {
            compress: {
              drop_debugger: true,
              drop_console: true
            }
          },
          sourceMap: false,
          parallel: true
        })
      );
    }
    config.plugins = [...config.plugins, ...plugins];
  }
};